IF EXISTS (SELECT * FROM SYSOBJECTS WHERE ID = OBJECT_ID('AuthorshipInsert') AND sysstat & 0xf = 4)
    DROP PROCEDURE [AuthorshipInsert]
GO
CREATE PROCEDURE [AuthorshipInsert]
(
    @AuthorshipId int = null output,
    @Value nvarchar,
    @CountOfPaint int,
    @CreateDate datetime,
    @UpdateDate datetime
)
AS
BEGIN
	SET NOCOUNT ON
	INSERT INTO [authorship](
        [value],
        [count_of_paint],
        [create_date],
        [update_date]
	)
	VALUES(
        @Value,
        @CountOfPaint,
        @CreateDate,
        @UpdateDate
	)
	SELECT @AuthorshipId = SCOPE_IDENTITY()
END
GO

IF EXISTS (SELECT * FROM SYSOBJECTS WHERE ID = OBJECT_ID('AuthorshipUpdate') AND sysstat & 0xf = 4)
    DROP PROCEDURE [AuthorshipUpdate]
GO
CREATE PROCEDURE [AuthorshipUpdate]
(
	@AuthorshipId int,
    @Value nvarchar,
    @CountOfPaint int,
    @CreateDate datetime,
    @UpdateDate datetime
)
AS
BEGIN
	
	UPDATE [authorship]
	SET
        [value]=@Value,
        [count_of_paint]=@CountOfPaint,
        [create_date]=@CreateDate,
        [update_date]=@UpdateDate
	WHERE
		[authorship_id] = @AuthorshipId

END
GO

IF EXISTS (SELECT * FROM SYSOBJECTS WHERE ID = OBJECT_ID('AuthorshipDelete') AND sysstat & 0xf = 4)
    DROP PROCEDURE [AuthorshipDelete]
GO
CREATE PROCEDURE [AuthorshipDelete]
(
	@AuthorshipId int	
)
AS
BEGIN
	
	DELETE
	FROM [authorship]
    WHERE
		[authorship_id] = @AuthorshipId
END
GO

IF EXISTS (SELECT * FROM SYSOBJECTS WHERE ID = OBJECT_ID('AuthorshipSelectOne') AND sysstat & 0xf = 4)
    DROP PROCEDURE [AuthorshipSelectOne]
GO
CREATE PROCEDURE [AuthorshipSelectOne]
(
	@AuthorshipId int
)
AS
BEGIN
	SET NOCOUNT ON	
	SELECT
		*
	FROM [authorship] (NOLOCK)
	WHERE
		([authorship_id] = @AuthorshipId)

END
GO

IF EXISTS (SELECT * FROM SYSOBJECTS WHERE ID = OBJECT_ID('AuthorshipSelectAll') AND sysstat & 0xf = 4)
    DROP PROCEDURE [AuthorshipSelectAll]
GO

CREATE PROCEDURE [AuthorshipSelectAll]
AS
BEGIN

	SET NOCOUNT ON
	SELECT
		authorship_id AS AuthorshipId,
		Value
	FROM [authorship] (NOLOCK)

END
GO
